home *** CD-ROM | disk | FTP | other *** search
- /* Printing.c */
-
- #include "AESimple.h"
-
- void PrintWindow(WindowPtr wp)
- {
- wiHand info = (wiHand)GetWRefCon(wp);
- THPrint printInfo;
- short pageNum = 1;
- short vPages, hPages;
- short vCount, hCount;
- short pageWidth, pageHeight;
- Rect pageRect;
- Rect pictRect;
- TPPrPort printPortPtr;
- TPrStatus printStatus;
-
- PrOpen();
- printInfo = (*info)->printInfo;
- PrValidate(printInfo);
- pageRect = (*printInfo)->prInfo.rPage;
- pictRect = (*info)->picBounds;
- pageWidth = (pageRect.right - pageRect.left);
- pageHeight = (pageRect.bottom - pageRect.top);
-
- /* Calculate how tall and wide the resulting image will be */
- vPages = (pictRect.bottom - pictRect.top) / pageHeight + 1;
- hPages = (pictRect.right - pictRect.left) / pageWidth + 1;
-
- printPortPtr = PrOpenDoc(printInfo,
- NIL,
- NIL);
-
- /* print each page */
- for (hCount = 0; hCount < hPages; hCount++)
- for (vCount = 0; vCount < vPages; vCount++) {
- PrOpenPage(printPortPtr, NIL);
- SetPort((GrafPtr)printPortPtr);
- pictRect = (*info)->picBounds;
- OffsetRect(&pictRect, -pageWidth * hCount, -pageHeight * vCount);
- DrawPicture((*info)->thePicture, &pictRect);
- PrClosePage(printPortPtr);
- }
-
- PrCloseDoc(printPortPtr);
-
- if ((PrError() == noErr) && ((*printInfo)->prJob.bJDocLoop == bSpoolLoop))
- PrPicFile(printInfo, NIL, NIL, NIL, &printStatus);
-
- SetPort(wp);
-
- PrClose();
- }
-
- Boolean ShowJobDialog(WindowPtr wp)
- {
- wiHand info = (wiHand)GetWRefCon(wp);
- Boolean result = TRUE;
- OSErr err = noErr;
-
- err = MyInteractWithUser(FALSE);
- if (err == noErr) {
- PrOpen();
- result = PrJobDialog((**info).printInfo);
- PrClose();
- }
- return result;
- } /* ShowJobDialog */
-
-
- Boolean ShowSetupDialog(WindowPtr wp)
- {
- wiHand info = (wiHand)GetWRefCon(wp);
- Boolean result = TRUE;
- OSErr err = noErr;
-
- err = MyInteractWithUser(FALSE);
- if (err == noErr) {
- PrOpen();
- result = PrStlDialog((**info).printInfo);
- PrClose();
- }
-
- return result;
- } /* ShowSetupDialog */
-